﻿using System;
using System.Collections.Generic;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Linq;
using System.Text;
using WebExam.Core.Repository;

namespace WebExam.DataEntities
{

    [Table(Name = "dbo.KM")]
    public partial class KM : Entity
    {
        private decimal _kmNum;

        private string _kmName;

        private bool _kmZF;

        private DateTime _yymm;

        private EntitySet<CJ> _CJ;

        private EntitySet<ExamPaper> _ExamPaper;

        public KM()
        {
            this._CJ = new EntitySet<CJ>(new Action<CJ>(this.attach_CJ), new Action<CJ>(this.detach_CJ));
            this._ExamPaper = new EntitySet<ExamPaper>(new Action<ExamPaper>(this.attach_ExamPaper), new Action<ExamPaper>(this.detach_ExamPaper));
        }

        [Column(Storage = "_kmNum", AutoSync = AutoSync.OnInsert, DbType = "Decimal(18,0) NOT NULL IDENTITY", IsPrimaryKey = true, IsDbGenerated = true)]
        public decimal KMNum
        {
            get
            {
                return this._kmNum;
            }
            set
            {
                if ((this._kmNum != value))
                {
                    this.SendPropertyChanging("KMNum");
                    this._kmNum = value;
                    this.SendPropertyChanged("KMNum",value);
                }
            }
        }

        [Column(Storage = "_kmName", DbType = "VarChar(30) NOT NULL", CanBeNull = false)]
        public string KMName
        {
            get
            {
                return this._kmName;
            }
            set
            {
                if ((this._kmName != value))
                {
                    this.SendPropertyChanging("KMName");
                    this._kmName = value;
                    this.SendPropertyChanged("KMName",value);
                }
            }
        }

        [Column(Storage = "_kmZF", DbType = "Bit")]
        public bool KMZF
        {
            get
            {
                return this._kmZF;
            }
            set
            {
                if ((this._kmZF != value))
                {
                    this.SendPropertyChanging("KMZF");
                    this._kmZF = value;
                    this.SendPropertyChanged("KMZF",value);
                }
            }
        }

        [Column(Storage = "_yymm", DbType = "DateTime")]
        public DateTime YYMM
        {
            get
            {
                return this._yymm;
            }
            set
            {
                if ((this._yymm != value))
                {
                    this.SendPropertyChanging("YYMM");
                    this._yymm = value;
                    this.SendPropertyChanged("YYMM",value);
                }
            }
        }

        [Association(Name = "KM_CJ", Storage = "_CJ", ThisKey = "KMNum", OtherKey = "KMNum")]
        public EntitySet<CJ> CJ
        {
            get
            {
                return this._CJ;
            }
            set
            {
                this._CJ.Assign(value);
            }
        }

        [Association(Name = "KM_ExamPaper", Storage = "_ExamPaper", ThisKey = "KMNum", OtherKey = "KMNum")]
        public EntitySet<ExamPaper> ExamPaper
        {
            get
            {
                return this._ExamPaper;
            }
            set
            {
                this._ExamPaper.Assign(value);
            }
        }

        private void attach_CJ(CJ entity)
        {
            entity.KM = this;
        }

        private void detach_CJ(CJ entity)
        {
            entity.KM = null;
        }

        private void attach_ExamPaper(ExamPaper entity)
        {
            entity.KM = this;
        }

        private void detach_ExamPaper(ExamPaper entity)
        {
            entity.KM = null;
        }
    }
}
